import React, {useRef} from 'react';
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import ProTable from '@ant-design/pro-table';
import { connect } from 'umi';
import { getSupplementList} from '../service';
import moment from 'moment';
import {Divider} from 'antd';
import { BPMStatusEnum } from '@/utils/constant'

const TableList = () => {
  const actionRef = useRef();

  const columns = [
    {
      title: '工号',
      hideInSearch: true,
      dataIndex: 'code',
    },
    {
      title: '姓名',
      dataIndex: 'name',
    },
    {
      title: '公司',
      dataIndex: 'orgname',
    },
    {
      title: '部门',
      dataIndex: 'unitname',
    },
    {
      title: '岗位',
      dataIndex: 'jobname',
    },
    {
      title: '创建日期',
      dataIndex: 'ctm',
      hideInSearch: true,
      render: (text) => {
        return text !== '-' ? moment(text).format('YYYY-MM-DD') : ''
      },
    },
    {
      title: '补卡数量',
      dataIndex: 'number',
      hideInSearch: true,
    },
    {
      title: '审批状态',
      dataIndex: 'status',
      hideInSearch: true,
      valueEnum: BPMStatusEnum
    },
    {
      title: '操作',
      dataIndex: 'option',
      valueType: 'option',
      render: (item, record) => (
        <>
          <a onClick={() => detail(record)}>详情</a>
          <Divider type="vertical"/>
          <a onClick={() => window.open(record.bpmDetailUrl)}>审批详情</a>
        </>
      ),
    },
  ];

  const detail = (id) => {
    console.log(id)
  };

  return (
    <PageHeaderWrapper>
      <ProTable
        actionRef={actionRef}
        rowKey="id"
        request={(params) => getSupplementList(params)}
        columns={columns}
      />
    </PageHeaderWrapper>
  )
};

export default connect(({}) => ({
}))(TableList)
